Skip to content

fix(test): inspect wp-ai-client prompt slot in refinement context test#1809

Merged
chubes4 merged 1 commit intomainfrom
fix/image-prompt-refinement-test
May 6, 2026
Merged

fix(test): inspect wp-ai-client prompt slot in refinement context test#1809
chubes4 merged 1 commit intomainfrom
fix/image-prompt-refinement-test

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 6, 2026

Summary

ImageGenerationPromptRefinementTest::test_refine_prompt_includes_post_context_when_provided was failing on main.

The assertion walked $captured_request['messages'] looking for the user message it had just sent. As of #1784 / #1791, RequestBuilder::wpAiClientPromptContext() lifts the latest user message into wp-ai-client's $request['prompt'] slot and routes earlier turns through with_history(). refine_prompt() only sends a single user message, so it lands in prompt and never appears in messages — the assertion was reading an empty string against 'Article context:'.

This is a test-side staleness, not a production bug. The other test in the same file (test_refine_prompt_uses_custom_style_guide) inspects system messages, which still flow through messages via system_instruction, so that one continued to pass.

Fix

Look at $captured_request['prompt'] first (where the active user message ends up), fall back to user-role messages in history. The assertion stays correct regardless of how many user turns the caller sends.

Test results

homeboy test data-machine --skip-lint:

  • Before: 1229 passed, 1 failed (this test), 3 skipped, 1233 total.
  • After: 1230 passed, 0 failed, 3 skipped, 1233 total.

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (openai/gpt-5.5)
  • Used for: Diagnosing the test failure against current RequestBuilder behavior, applying the test-side fix, and PR preparation. Chris remains responsible for review and merge.

ImageGenerationPromptRefinementTest::test_refine_prompt_includes_post_context_when_provided
walked $captured_request['messages'] looking for the user message it had
just sent. As of #1784/#1791, RequestBuilder::wpAiClientPromptContext()
lifts the latest user message into wp-ai-client's $request['prompt'] slot
and routes earlier turns through with_history(); refine_prompt() only
sends a single user message, so it lands in 'prompt' and never appears in
'messages'. The assertion was reading an empty string against
'Article context:'.

Look at 'prompt' first, fall back to user-role history messages, so the
test stays correct regardless of how many user turns the caller sends.
@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci Bot commented May 6, 2026

Homeboy Results — data-machine

Lint

lint — passed

ℹ️ Full options: homeboy docs commands/lint
Deep dive: homeboy lint data-machine --changed-since b83bb66

Test

test — passed

  • 13 passed

ℹ️ Auto-fix lint issues: homeboy refactor data-machine --from lint --write
ℹ️ Collect coverage: homeboy test data-machine --coverage
ℹ️ Save test baseline: homeboy test data-machine --baseline
ℹ️ Pass args to test runner: homeboy test -- [args]
ℹ️ Full options: homeboy docs commands/test
Deep dive: homeboy test data-machine --changed-since b83bb66

Audit

audit — passed

  • dead_code — 1 finding(s)
  • Total: 1 finding(s)

Deep dive: homeboy audit data-machine --changed-since b83bb66

Tooling versions
  • Homeboy CLI: homeboy 0.157.1+1baceb8a
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: ebde078
  • Action: Extra-Chill/homeboy-action@v2

@chubes4 chubes4 merged commit 68213a5 into main May 6, 2026
3 checks passed
@chubes4 chubes4 deleted the fix/image-prompt-refinement-test branch May 6, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant